#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
bool isPalindromicNumber(char N[])
{
    int len=strlen(N);
    int mid=len/2;
    bool flag=true;
    for (int i=0; i<mid ; ++i )
    {
        if (N[i]!=N[len-i-1])
        {
            flag=false;
            break;
        }
    }
    return flag;
}
int main_1024_1()
{
    LL N1,N2,K,steps=0;
    scanf("%lld%lld",&N1,&K);
    char Ns[30]= {0};
    while (steps<=K)
    {
        sprintf(Ns,"%lld",N1);
        if (isPalindromicNumber(Ns))
        {
            break;
        }
        else
        {
            reverse(Ns,Ns+strlen(Ns));
            sscanf(Ns,"%lld",&N2);
            N1+=N2;
        }
        ++steps;
    }
    reverse(Ns,Ns+strlen(Ns));
    printf("%s\n",Ns);
    printf("%lld",min(steps,K));
    return 0;
}
